<?php

namespace app\common\model\Games;

use think\Model;

class Gameorder extends Model
{
    protected $name = 'gameorder';

    protected $autoWriteTimestamp = true;

    protected $createTime = 'createtime'; //时间戳的字段名

    protected $updateTime = false; //关闭更新时自动写入

    protected $field = true; //过滤

    protected $append = [
        "createtime_text"
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        $createtime = isset($data['createtime']) ? $data['createtime'] : '';
        if ($createtime) {
            return date('Y-m-d', $createtime);
        } else {
            return '无';
        }
    }


    //左联用户表
    public function gameuser()
    {
        return $this->belongsTo("app\common\model\Games\Gameuser", "gameuserid", "id", [], "LEFT")->setEagerlyType(0);
    }

    //左联vip表
    public function vip()
    {
        return $this->belongsTo("app\common\model\Games\Gamevip", "vipid", "id", [], "LEFT")->setEagerlyType(0);
    }
}
